package io.mybatis.example.springboot.controller;

import io.mybatis.common.core.DataResponse;
import io.mybatis.common.core.RowsResponse;

import io.mybatis.example.springboot.model.QrtzBlobTriggers;
import io.mybatis.example.springboot.service.QrtzBlobTriggersService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * QRTZ_BLOB_TRIGGERS - Blob类型的触发器表
 *
 * @author mkj
 */
@RestController
@RequestMapping("qrtzBlobTriggerses")
public class QrtzBlobTriggersController {

  @Autowired
  private QrtzBlobTriggersService qrtzBlobTriggersService;

  @PostMapping
  public DataResponse<QrtzBlobTriggersDO> save(@RequestBody QrtzBlobTriggersDO qrtzBlobTriggers) {
    return DataResponse.ok(qrtzBlobTriggersService.save( qrtzBlobTriggers));
  }

  @GetMapping
  public RowsResponse<QrtzBlobTriggersDO> findList(@RequestBody QrtzBlobTriggersDO qrtzBlobTriggers) {
    return RowsResponse.ok(qrtzBlobTriggersService.findList( qrtzBlobTriggers));
  }

  @GetMapping(value = "/{id}")
  public DataResponse<QrtzBlobTriggersDO> findById(@PathVariable("id") Long id) {
    return DataResponse.ok(qrtzBlobTriggersService.findById(id));
  }

  @PutMapping(value = "/{id}")
  public DataResponse<QrtzBlobTriggersDO> update(@PathVariable("id") Long id, @RequestBody QrtzBlobTriggersDO qrtzBlobTriggers) {
    qrtzBlobTriggers.setId(id);
    return DataResponse.ok(qrtzBlobTriggersService.update( qrtzBlobTriggers));
  }

  @DeleteMapping(value = "/{id}")
  public DataResponse<Boolean> deleteById(@PathVariable("id") Long id) {
    return DataResponse.ok(qrtzBlobTriggersService.deleteById(id) == 1);
  }

}
